package com.cw1.principle.segregation2;

/**
 * 理解接口隔离原则
 */
public class segregation1 {
    public static void main(String[] args) {
        Aa aa = new Aa();
        aa.dep1(new Cc());
        aa.dep2(new Bb());
        aa.dep3(new Bb());
        aa.dep4(new Cc());
        aa.dep5(new Cc());
    }
}

/**
 * 通过Aa方法实现接口的实现类
 */
class Aa{
    public void dep1(inter1 inter1){
        inter1.function1();
    }

    public void dep2(inter2 inter2){
        inter2.function2();
    }

    public void dep3(inter2 inter2){
        inter2.function3();
    }

    public void dep4(inter3 inter3){
        inter3.function4();
    }

    public void dep5(inter3 inter3){
        inter3.function5();
    }
}



interface inter1{
  void  function1();
}

interface inter2{
    void  function2();
    void  function3();
}

interface inter3{
    void  function4();
    void  function5();
}

class Bb implements inter1,inter2{

    public void function1() {
        System.out.println("Bb类实现了function1");
    }

    public void function2() {
        System.out.println("Bb类实现了function2");
    }

    public void function3() {
        System.out.println("Bb类实现了function3");
    }
}

class Cc implements inter1,inter3{

    public void function1() {
        System.out.println("Cc类实现了function1");
    }

    public void function4() {
        System.out.println("Cc类实现了function4");
    }

    public void function5() {
        System.out.println("Cc类实现了function5");
    }
}

